var e = getApp();

Page({
    data: {
        show: !1,
        value: "",
        pageindx: 0,
        member: "",
        level_id: 0,
        page: 1,
        info: {},
        val_member: ""
    },
    onLoad: function(e) {
        this.getSearch();
    },
    souSuo: function() {
        this.setData({
            member: this.data.val_member
        }), this.getSearch();
    },
    keyValue: function(e) {
        var t = e.detail.value;
        this.setData({
            val_member: t
        });
    },
    chooseTabData: function(e) {
        console.log(e), this.setData({
            pageindx: e.detail.index,
            level_id: e.detail.index,
            page: 1
        }), this.getSearch();
    },
    toUpdate: function(e) {
        var t = e.currentTarget.dataset.uid.uid;
        console.log(e), this.setData({
            show: !0,
            upuid: t
        });
    },
    raidinp: function(e) {
        console.log(e), this.setData({
            value: Number(e.detail)
        });
    },
    resultAdd: function() {
        e._isTextEmpty(this.data.value) ? wx.showToast({
            title: "请选择升级等级",
            icon: "none",
            duration: 1e3
        }) : (this.setData({
            show: !1,
            levelId: this.data.value
        }), this.uplevel());
    },
    cancel: function() {
        this.setData({
            show: !1
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.current_page >= this.data.last_page ? wx.showToast({
            title: "暂无更多",
            icon: "none",
            duration: 1e3
        }) : (this.setData({
            page: this.data.page + 1
        }), wx.showLoading({
            title: "加载中"
        }), this.getNext());
    },
    onShareAppMessage: function() {},
    getSearch: function() {
        var t = this, a = {
            member: this.data.member,
            level_id: this.data.level_id,
            page: this.data.page
        }, s = e.getNetAddresss("plugin.team-sales.api.team.index");
        e._postNetWork({
            url: s,
            data: a,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (console.log(a), t.setData({
                    info: a.data,
                    list: a.data.member.data,
                    current_page: a.data.member.current_page,
                    last_page: a.data.member.last_page
                })) : (wx.showToast({
                    title: a.msg,
                    icon: "none"
                }), console.log(a.msg));
            }
        });
    },
    getNext: function() {
        var t = this, a = {
            member: this.data.member,
            level_id: this.data.level_id,
            page: this.data.page
        }, s = e.getNetAddresss("plugin.team-sales.api.team.index");
        e._postNetWork({
            url: s,
            data: a,
            success: function(e) {
                var a = e.data;
                1 == a.result ? (console.log(a), t.setData({
                    info: a.data,
                    list: t.data.list.concat(a.data.member.data),
                    current_page: a.data.member.current_page,
                    last_page: a.data.member.last_page
                }), wx.hideLoading({
                    complete: function(e) {}
                })) : (wx.showToast({
                    title: a.msg,
                    icon: "none"
                }), console.log(a.msg), wx.hideLoading({
                    complete: function(e) {}
                }));
            }
        });
    },
    uplevel: function(t) {
        var a = this, s = {
            member_id: this.data.upuid,
            level_id: this.data.levelId
        }, o = e.getNetAddresss("plugin.team-sales.api.team.upgrade");
        e._postNetWork({
            url: o,
            data: s,
            success: function(e) {
                var t = e.data;
                1 == t.result ? (console.log(t), wx.showToast({
                    title: t.msg,
                    icon: "none",
                    duration: 1e3
                }), a.getSearch()) : wx.showToast({
                    title: t.msg,
                    icon: "none"
                });
            },
            fail: function(e) {
                wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            }
        });
    }
});